package com.yanqu.road.server.cmd.estatewar;

import com.yanqu.road.server.pb.EstateWarPb;
import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.entity.estatewar.UserEstateFloor;
import com.yanqu.road.pb.estatewar.EstateWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.manger.player.EstateWarMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;

import java.util.List;

@Cmd(code = Protocol.S_ESTATE_WAR_GET_ESTATE_INFO, desc = "获取能战斗的楼层")
public class EstateWarGetEstateInfoCmd extends AbstractCommand {

	private List<UserEstateFloor> estateFloorList;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		if(SystemOpenMgr.systemOpen(player, eSystemId.EstateWar.getValue())) {
			estateFloorList = EstateWarMgr.getEstateInfo(player);
		}
	}

	@Override
	public void sendData(GamePlayer player) {
		EstateWarProto.EstateWarFloorListMsg.Builder respMsg = EstateWarPb.parseEstateWarFloorListMsg(estateFloorList);
		player.sendPacket(Protocol.U_ESTATE_WAR_GET_ESTATE_INFO, respMsg);
	}
}
